<!--
 * @Description: 
 * @Version: 
 * @Autor: ps
 * @Date: 2022-04-12 12:03:19
 * @LastEditors: ps
 * @LastEditTime: 2022-07-04 14:07:37
-->
<template>
  <div class="apsDialogSub">
    <el-dialog
      title="审核"
      :visible.sync="audit.auditShow"
      :before-close="closeAudit"
      width="40%"
      append-to-body
    >
      <el-form
        ref="auditForm"
        :model="audit.auditForm"
        :rules="audit.auditRules"
        label-width="100px"
      >
        <el-form-item label="审核状态" prop="auditStatus">
          <el-select
            v-model="audit.auditForm.auditStatus"
            placeholder="请选择审核状态"
            clearable
          >
            <el-option
              v-for="item in dict.type.audit_status_c"
              :key="item.label"
              :label="item.label"
              :value="+item.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="审核意见" v-if="showReply" prop="auditReply">
          <el-input
            placeholder="请输入审核意见"
            type="textarea"
            :rows="4"
            maxlength="200"
            show-word-limit
            v-model="audit.auditForm.auditReply"
          >
          </el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" :loading="loading" @click="submitAudit"
          >审核</el-button
        >
        <el-button plain size="small" @click="closeAudit">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
export default {
  name: "apsDialogSub",
  dicts: ["audit_status_c"],
  props: {
    auditForm: {
      type: Object,
      default: () => {
        return {};
      },
    },
    loading: {
      type: Boolean,
      default: false,
    },
    showReply: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      audit: {
        auditShow: true,
        auditForm: {
          auditReply: "",
          auditStatus: undefined,
        },
        auditRules: {
          auditStatus: [
            {
              required: true,
              message: "请选择审核状态",
              trigger: "change",
            },
          ],
        },
      },
    };
  },
  mounted() {
    if (Object.keys(this.auditForm).length) {
      this.audit.auditForm = this.auditForm;
    }
  },
  methods: {
    submitAudit() {
      let $this = this;
      this.$refs["auditForm"].validate((valid) => {
        if (valid) {
          $this.$emit("submitAudit", $this.audit.auditForm);
        }
      });
    },
    closeAudit() {
      this.audit.auditShow = false;
      this.$emit("closeAudit", false);
    },
  },
};
</script>
<style lang="scss" scoped>
</style>
